package com.kfm.hotel.controller;

import com.github.pagehelper.PageInfo;
import com.kfm.hotel.domain.SysDict;
import com.kfm.hotel.service.SysDictService;
import com.kfm.hotel.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/sysdict")
public class SysDictController {

    @Autowired
    private SysDictService service;

    @GetMapping
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView("sysdict/index");
        return modelAndView;
    }

    @GetMapping("/list")
    public R list(@RequestParam(defaultValue = "1") Integer page,
                  @RequestParam(defaultValue = "10") Integer limit,
                  SysDict entity) {
        PageInfo<SysDict> pageInfo = service.list(entity, page, limit);
        return R.ok(pageInfo);
    }

    @GetMapping("/add")
    public ModelAndView add() {
        ModelAndView modelAndView = new ModelAndView("sysdict/add");
        return modelAndView;
    }
}
